<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/res/include/base-head.jsp"%>
<%@include file="/res/include/jquery-easyui.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/draw/drawItem.js"></script>
</head>
<body>
<form id="data-form">
	<div class="form_item">
		<dl>
			<dt>名称：</dt>
			<dd>
				<input  type="text" id="name" name="name"/>
			</dd>
		</dl>
		<dl>
			<dt>图片：</dt>
			<dd>
				<ul class="product_imglist img_imglist">
						<li><a href="javascript:;" class="item" id="pic0" onclick="admin.drawItem.addImg('pic0')">添加图片</a>
						</li>
				</ul>
				<em class="p0">上传4:3的JPG/PNG/BMP图片，建议：60*48px</em>
			</dd>
		</dl>
		<dl>
			<dt>优惠券：</dt>
			<dd>
				<select name="couponId" id="couponId">
					<option value="">请选择</option>
					<c:forEach var="item" items="${couponList}">
						<option value="${item.id}">${item.name}</option>
					</c:forEach>
				</select>
			</dd>
		</dl>
		<p class="page_btn"><input type="button" id="saveBtn" value="保存" class="btn_blue" onclick="add();"/></p>
	</div>
</form>
<script type="text/javascript">
	function add(){
		var data = $('#data-form').form('jsonObject');
		if($("#bizzType").val()==3||$("#bizzType").val()==4){
			var categoryId=$("input[name='baseVo']:checked").val();
			if(null==categoryId||''==categoryId){
				top.showInfo('请选择类目');
				return;
			}
			data.categoryId=categoryId;
		}
		var img = "";
		var imglist = $(".img_imglist img");
		if (imglist && imglist.length > 0) {
			imglist.each(function() {
				if (img == "") {
					img += $(this).attr("src").replace(imgFilePath, "");
				} else {
					img += ";" + $(this).attr("src").replace(imgFilePath, "");
				}
			});
		} else {
			top.showInfo('请上传图片');
			return;
		}
		var url = contextPath + '/draw/item/add';
		data.img = img;
		 $.post(url, data, function(data) {
			top.addTab("",'优惠卷列表', contextPath+'/draw/item/list');
		}); 
	}
</script>
</body>
</html>
